package com.systemframework.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.systemframework.sys.entity.SysUserRole;
import com.systemframework.sys.mapper.SysUserRoleMapper;
import com.systemframework.sys.service.SysUserRoleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author summer
 * @date 2023-03-20 15:04
 */
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {

    @Override
    public void saveUserRole(List<SysUserRole> sysUserRole, Integer userId) {
        LambdaQueryWrapper<SysUserRole> eq = Wrappers.lambdaQuery(SysUserRole.class).eq(SysUserRole::getUserId, userId);
        this.remove(eq);
        this.saveBatch(sysUserRole);
    }


}
